package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.bean.OrderDetail;
import com.itheima.dao.OrderDetailDao;
import com.itheima.service.OrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class OrderDetailServiceImpl implements OrderDetailService {
    @Autowired
    private OrderDetailDao orderDetailDao;
    @Override
    public int add(OrderDetail orderDetail) {
        return orderDetailDao.insert(orderDetail);
    }

    @Override
    public Integer findCount(Long orderId) {
        //创建条件查询对象
        LambdaQueryWrapper<OrderDetail> qw = new LambdaQueryWrapper<>();
        //创建查询的条件
        qw.eq(OrderDetail::getOrderId,orderId);
        //调用dao进行查寻
        return orderDetailDao.selectCount(qw);
    }

    @Override
    public OrderDetail findByOrderId(Long orderId) {
        return null;
    }
}
